package com.enhe.gck.fg;

import cn.hutool.core.util.StrUtil;
import com.enhe.gck.communal.PublicMethod;
import com.enhe.gck.communal.PublicReturn;
import com.kuangkie.carbon.common.AggregateVO;
import com.kuangkie.carbon.record.RecordQueryProConJunctionFactory;
import org.springframework.stereotype.Repository;
import com.kuangkie.carbon.fg.FuncGroupContext;
import com.kuangkie.carbon.fg.ImproveResultFactory;
import com.kuangkie.carbon.fg.SecondRoundImproveFuncGroup;
import com.kuangkie.carbon.record.FGRecordComplexus;
import com.kuangkie.carbon.record.ProRecord;
import com.enhe.gck.CarbonBaseConstant; //模型Code
import com.enhe.gck.CarbonEnumKeyValue; //枚举字典信息
import com.enhe.gck.CarbonRelationType; //关系类型Code
import com.enhe.gck.item.InvoiceInfoHWANE19375Item; // 模型属性Code

@Repository(value = "hwane19375366042330866425862")
public class InvoiceInfoHWANE19375BNB implements SecondRoundImproveFuncGroup{
	
	@Override
	public void secondImprove(FuncGroupContext context, ProRecord proRecord, FGRecordComplexus recordComplexus,
			ImproveResultFactory improveResultFactory) {
		if(proRecord.isNew()){
			String customerCode=proRecord.getGuestRecordCode(CarbonRelationType.RR_开票信息_属于客户_客户管理);
			if(StrUtil.isNotBlank(customerCode)){
				RecordQueryProConJunctionFactory query=PublicMethod.query(CarbonBaseConstant.开票信息_kpxx);
				query.getRelationCriterionFactory(CarbonBaseConstant.客户管理_khgl)
						.setInRelationTypes(CarbonRelationType.RR_开票信息_属于客户_客户管理)
						.setInGuestCodes(customerCode);
				AggregateVO aggregateVO = query.goBack().queryCount();
				if (aggregateVO!=null&&aggregateVO.getCount()>0){
					PublicMethod.returnMessage(improveResultFactory, PublicReturn.INVOICING_10);
					return;
				}
			}
		}
	}
	
}
